#include <math.h>

extern const double height;

inline double deg2rad(double deg)
{
  return deg * M_PI/180.0L;
}

inline double rad2deg(double rad)
{
  return rad * 180.0L/M_PI;
}

/* at zero azimuth */
double angle2distance(double angle)
{
  return height / sin(deg2rad(angle));
}

/* at zero azimuth */
double distance2angle(double d)
{
  return rad2deg(asin(height / d));
}

double angles_to_distance(double elevation, double azimuth)
{
  return height / (sin(deg2rad(elevation)) * cos(deg2rad(azimuth)));
}

